package program;

import java.awt.*;
import java.awt.event.*;


public class Okienko implements WindowListener, ActionListener{

	Button b0,b1;
	Label l1;
        public static Label godzina;
	String wypelnienie = "Nie";
	String TekstLabel,Kolor = "Brak";
	Checkbox cb1;
	Checkbox rb1, rb2, rb3;
        String czas;


	public void createAndShowGUI(){

            Watek thr = new Watek();
            thr.start();

		Frame okno = new Frame();
		okno.setSize(500,300);
		okno.setTitle("Aris - Project");

                Panel pWest = new Panel();
                Panel pSouth = new Panel();
                Panel pEast = new Panel();
                Panel pCenter = new Panel();

		cb1 = new Checkbox("Wypełnienie");

		pWest.setLayout(new GridLayout(3,1));
		pEast.setLayout(new GridLayout(2,1));
                pSouth.setLayout(new GridLayout(1,2));

		CheckboxGroup cbg;
		cbg = new CheckboxGroup();
		rb1 = new Checkbox("Zielony", cbg, false);
		rb2 = new Checkbox("Niebieski", cbg, false);
		rb3 = new Checkbox("Czerwony", cbg, false);
		pWest.add(rb1);
		pWest.add(rb2);
		pWest.add(rb3);

                godzina = new Label("Godzina: kdjflksj lskdjfsdf");
                pSouth.add(cb1);
                pSouth.add(godzina);

		Choice Figura = new Choice();
		Figura.add("Kwadarat");
		Figura.add("Koło");

		b0 = new Button("Rysuj");
		b0.addActionListener(this);

		pEast.add(b0);

		l1 = new Label("Witamy");
		pCenter.add(l1);

		okno.add(Figura, BorderLayout.NORTH);
		okno.add(pSouth, BorderLayout.SOUTH);
		okno.add(pWest, BorderLayout.WEST);
		okno.add(pEast, BorderLayout.EAST);
		okno.add(pCenter, BorderLayout.CENTER);

		okno.addWindowListener(this);

		okno.setVisible(true);
	}


	public void actionPerformed(ActionEvent ae) {
		if (ae.getSource() == b0){
			if (cb1.getState() == true)  wypelnienie = "Tak";
			if (cb1.getState() == false) wypelnienie = "Nie";
			if (rb1.getState() == true) Kolor = "Zielony";
			if (rb2.getState() == true) Kolor = "Niebieski";
			if (rb3.getState() == true) Kolor = "Czerwony";

			TekstLabel = "Wypełnienie: " + wypelnienie + " Kolor: " + Kolor;
			l1.setText(TekstLabel);
		}
	}

	//zdefiniowanie metod
	public void windowActivated(WindowEvent arg0) {}
	public void windowClosed(WindowEvent arg0) {}
	public void windowClosing(WindowEvent arg0) {System.exit(0);}
	public void windowDeactivated(WindowEvent arg0) {}
	public void windowDeiconified(WindowEvent arg0) {}
	public void windowIconified(WindowEvent arg0) {}
	public void windowOpened(WindowEvent arg0) {}

  }